/**
 * @param {number[][]} matrix
 * @return {void} Do not return anything, modify matrix in-place instead.
 * 输入：matrix = [[1,1,1],[1,0,1],[1,1,1]]
输出：[[1,0,1],[0,0,0],[1,0,1]]
 */
var setZeroes = function (matrix) {
  for (const key in matrix) {
    const item = matrix[key]
    for (const index in item) {
      if (item[index] === 0) {
        let i = 0
        while (i < item.length) {
          if (item[i] !== 0) item[i] = 'k'
          i++
        }
        let j = 0
        while (j < matrix.length) {
          if (matrix[j][index] !== 0) matrix[j][index] = 'k'
          j++
        }
      }
    }
  }
  for (let item in matrix) {
    for (let item1 in matrix[item]) {
      matrix[item][item1] === 'k' && (matrix[item][item1] = 0)
    }
  }
  return matrix
}
console.log(
  setZeroes([
    [1, 1, 1],
    [1, 0, 1],
    [1, 1, 1]
  ])
)
